var Feedback = {
	send: function() {
		question = $("#feedback").val();
		if (question == "") {
			$alert("问题内容为空");
			return;
		}
		var time = new Date().pattern("yyyy-MM-dd");
		$ajax({
			url: "/feedback/upsert",
			data: {
				from: CurrentUser._id,
				question: question
			},
			success: function(res) {
				PCall("feedback_list", "CCall('Feedback.listInit();')");
				$alert("发送成功,感谢您的配合！");
				WinClose();
			}
		});
	},
	listInit: function() {
		$ajax({
			url: "/feedback/list",
			data: {
				from: CurrentUser._id,
			},
			success: function(res) {
				var length = res.result.count;
				if (length == 0) 
					return $("#ctn").html(" <div id='nofeed' class='t_blu umt_6 ufb tx-c'>您尚未反馈任何问题！</div>");
					
				var result = res.result.results;
				var html = "";
				for (var i = 0; i < length; i++) {
					html += '<div class="ubb b-gra up_base">' +
						'	<div class="ub ub-ver">' +
						'    	<div class="c_base upb_p5">请问：</div>' +
						'		<div class="ulev-1 upb_p5">　　' + result[i].question.replace(/\n/g, "</br>") + '</div>' +
						'		<div class="ub ub-pe upb_p5 ulev-2 t-gra">' + new Date(result[i].create).pattern("yyyy-MM-dd HH:mm") + '</div>' +
						'    </div>'
					if (result[i].answer != undefined) {
						html += '	 <div class="ub ub-ver">' +
								'   	<div class="t-org upb_p5">回复：</div>' +
								'		<div class="ulev-1 upb_p5">　　' + result[i].answer.replace(/\n/g, "</br>") + '</div>' +
								'		<div class="ub ub-pe upb_p5 ulev-2 t-gra">' + new Date(result[i].aDate).pattern("yyyy-MM-dd HH:mm") + '</div>' +
								'   </div>'
					}
					html += '</div>	';
				}
				$("#ctn").html(html);
			}
		});
	}
}